import { ref } from 'vue'
import { adapter, request } from '@/request'
import { tallCostdel } from '@/core/api/account'
import is from '@/utils/is'
import { message } from 'ant-design-vue'

interface Params {
  id?: number
}

export default function tallCostdelFn() {
  const service = adapter<any>(request)
  const loading = ref(false)
  const fetch = (data: Params) => {
    const { url, method } = tallCostdel()
    loading.value = true

    return service({
      config: {
        url,
        method,
        data
      },
      error: (err) => {
        if (is.error(err)) {
          message.error(err.message)
        }
      },
      done: () => {
        loading.value = false
      }
    })
  }

  return [null, fetch, loading] as const
}
